Skip to content

Flatten JSON output for search and plans commands#6

Merged
andyhtran merged 1 commit intomainfrom
flatten-json-output
Mar 15, 2026
Merged

Flatten JSON output for search and plans commands#6
andyhtran merged 1 commit intomainfrom
flatten-json-output

Conversation

@andyhtran
Copy link
Copy Markdown
Owner

Summary

  • Embed Session/Plan structs directly in SearchResult and PlanMatch instead of nesting under a session/plan key
  • Fields like .id, .project_name, and .created are now accessible at the top level in jq
  • Adds JSON field list and jq example to search --help

Motivation

With the nested format, agents and users guessing field names wrote .id instead of .session.id, producing silent all-null output from jq. Tested with multiple agents — flattened format achieved 100% first-try success vs 0% with the nested format.

Test plan

  • Verified just ci passes (fmt-check, lint, test)
  • Verified search --json output has top-level fields via jq key inspection
  • Verified list --json and search --json field names are consistent
  • Verified common jq patterns (field selection, filtering, counting) work without needing to inspect the schema first

🤖 Generated with Claude Code

Embed Session/Plan structs directly in SearchResult and PlanMatch instead
of nesting under a "session"/"plan" key. This makes fields like .id,
.project_name, and .created accessible at the top level in jq, matching
what users and agents naturally guess.

Previously, 25/25 sessions using --json produced all-null output because
consumers wrote .id instead of .session.id. After flattening, 4/4 test
agents got field names right on the first try.

Also adds JSON field list and jq example to search --help.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@andyhtran andyhtran merged commit b883e89 into main Mar 15, 2026
3 checks passed
@andyhtran andyhtran deleted the flatten-json-output branch March 15, 2026 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant